﻿using System;
using System.Configuration;
using System.Dynamic;
using Interop.VoucherCO_SA;
using Interop.USSAServer;
using SaVoucherService;
using System.IO;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Reflection;
using System.Xml;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using MSXML2;
using U8SrvTrans;
using U8;




namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = "demo";
            string pass = "";
            String sSubId = "AS";
            String sAccID = ConfigurationManager.AppSettings["ZTH"].ToString();
            String sYear = DateTime.Now.Year.ToString();
            String sDate = DateTime.Now.ToString("yyyy-MM-dd");
            String sServer = ConfigurationManager.AppSettings["SERVER"].ToString();
            String sUserID = name; ;
            String sSerial = "";

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            if (!u8Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref pass, ref sDate, ref sServer, ref sSerial))
            {
                string aaa = u8Login.ShareString;
                return;
            }
            else
            {
                string errMsg = string.Empty;
                string cCode = string.Empty;
                try
                {
                    //定义表头Dom对象
                    StringBuilder Strsql = new StringBuilder();
                    Strsql.Append("select bWireless='1',editprop='A',fornet='1','cvouchtype'='sa19',*   from SA_CusPriceJustMainView where id = 1000009343 ");

                    MSXML2.DOMDocument domHead = getDom(Strsql.ToString(), u8Login.UfDbName);//生成表头DOM

                    Strsql = new StringBuilder();
                    Strsql.Append("select editprop='A',*  from  SA_CusPriceJustDetailView   where id=1000009343");
                    MSXML2.DOMDocument domBody = getDom(Strsql.ToString(), u8Login.UfDbName);//生成表体DOM

                    Interop.USSAServer.clsSystem Cls = new Interop.USSAServer.clsSystem();
                    //定义表头Dom对象
                    Cls.Init(u8Login); ;
                    Interop.VoucherCO_SA.ClsVoucherCO_SAClass Co = new Interop.VoucherCO_SA.ClsVoucherCO_SAClass();
                    //初始化CO
                    Cls.Init(u8Login);
                    Cls.INIMyInfor();
                    Cls.bManualTrans = false;



                    Co.Init(Interop.VoucherCO_SA.VoucherTypeSA.SODetails, u8Login, null, "CS", Cls);
                    object curID = "";
                    string meg = Co.Save(domHead, domBody, 0, ref curID);


                }
                catch
                {

                }
          
             }
        
        }

        public static MSXML2.DOMDocument getDom(string Strsql, string strConn)
        {
            MSXML2.DOMDocument dom = new MSXML2.DOMDocument();
            ADODB.Connection conn = new ADODB.Connection();
            ADODB.Recordset rs = new ADODB.Recordset();

            conn.Open(strConn);

            rs.Open(Strsql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
            rs.Save(dom, ADODB.PersistFormatEnum.adPersistXML);

            return dom;
        }
    }
}